package com.chanel.iamframework.core.service;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.chanel.iamframework.core.domain.Group;
import com.chanel.iamframework.validation.annotation.Validate;

@Validate
public interface GroupService {

	/**
	 * Get Group by id
	 * @param groupId Identity
	 * @return Group entity
	 */
	Group getGroup(@NotNull Long groupId);

	/**
	 * Persist Group
	 * @param group entity
	 * @return true if the object is persisted, false otherwise.
	 */
	void createGroup(@NotNull @Valid Group group);

	/**
	 * Update Group by id
	 * @param group entity
	 * @return true if the object is updated, false otherwise.
	 */
    boolean updateGroup(@NotNull @Valid Group group);

    /**
     * Delete Group by id
     * @param groupId Identity
     * @return true if the object is deleted, false otherwise.
     */
    boolean deleteGroup(@NotNull Long groupId);

	/**
     * Load Roles by GroupId into the returned {@link Group} instance.
     * @param groupId identity
     * @return {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Role}
     */
	Group loadRoles(@NotNull Long groupId);

	/**
     * Load Users by GroupId into the returned {@link Group} instance.
     * @param groupId identity
     * @return {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.User}
     */
	Group loadUsers(@NotNull Long groupId);

	/**
	 * Load Applications by GroupId into the returned {@link Group} instance.
	 * @param groupId identity
	 * @return {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 */
	Group loadApplications(@NotNull Long groupId);

	/**
	 * Add Group, Role association
	 * @param groupId identity
	 * @param roleId identity
	 * @return The number of rows affected by the insert
	 */
	 /**
	  * Add Group, Roles association
	  * @param group {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Role}
	  */
	void addRoles(@NotNull Group group);

	/**
	 * Delete Group, Role association
	 * @param groupId identity
	 * @param roleId identity
	 * @return The number of rows affected by the insert
	 */
	/**
	 * Delete Group, Roles association
	 * @param group {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Role}
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean deleteRoles(@NotNull Group group);

	/**
	 * Add Group, Applications association
	 * @param group {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 */
	void addApplications(@NotNull Group group);

	/**
	 * Delete Group, Applications association
	 * @param group {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean deleteApplications(@NotNull Group group);

	/**
	 * Add Group, Users association
	 * @param group {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.User}
	 */
	void addUsers(@NotNull Group group);

	/**
	 * Delete Group, Users association
	 * @param group {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.User}
	 * @return true if the object is persisted, false otherwise.
	 */
	boolean deleteUsers(@NotNull Group group);
}
